package com.yksj.healthtalk.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.yksj.healthtalk.ui.R;

public class CustomerselfProblemDetailAdapter extends  BaseAdapter{


private Context context;
private LayoutInflater inflater;
ViewHolder holder ;
//String format;

public  CustomerselfProblemDetailAdapter(Context context){
	this.context = context;
	inflater  = LayoutInflater.from(context);
	
//	format = context.getResources().getString(R.string.problem_support);
}

@Override
public int getCount() {
	// TODO Auto-generated method stub
	return 5;
}

@Override
public Object getItem(int position) {
	// TODO Auto-generated method stub
	return null;
}

@Override
public long getItemId(int position) {
	// TODO Auto-generated method stub
	return 0;
}

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
	if (position == 0) {
		holder = new ViewHolder();
		convertView = inflater.inflate(R.layout.problem_customerself_detail_one, null);
		holder.questionTime = (TextView) convertView.findViewById(R.id.questionTime);
		holder.header = (ImageView)convertView.findViewById(R.id.header);
		holder.content = (TextView)convertView.findViewById(R.id.name);
		holder.delete = (Button) convertView.findViewById(R.id.delete);
		holder.edit = (Button) convertView.findViewById(R.id.edit);
	}else {
		if (convertView== null || convertView.getTag() != null ) {
			convertView = inflater.inflate(R.layout.problem_customerself_detail_other, null);
			holder.questionTime = (TextView) convertView.findViewById(R.id.questionTime);
			holder.header = (ImageView)convertView.findViewById(R.id.header);
			holder.content = (TextView)convertView.findViewById(R.id.name);
			holder.support = (Button) convertView.findViewById(R.id.support);
			holder.best_answer = (Button) convertView.findViewById(R.id.best_answer);
			holder.add_question = (Button) convertView.findViewById(R.id.add_question);
			convertView.setTag(holder);
		}else {
			holder = 	(ViewHolder) convertView.getTag();
		}
		if (holder.support != null) {
			holder.support.setText(String.format(context.getString(R.string.problem_support), 6));
		}
		
	}
	
	
	
	return convertView;
}


class ViewHolder{
	TextView questionTime;
	ImageView header;
	TextView content;
	//第一项
	Button delete;
	Button edit;
	
//	其余项
	Button support;
	Button best_answer;
	Button add_question;
}

}

